home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / hershey / src / getchar.c < prev    next >
C/C++ Source or Header  |  1994-04-12  |  850b  |  59 lines

  1. #include <stdio.h>
  2.  
  3. #ifdef SGI
  4. #include <gl.h>
  5. #include <device.h>
  6. #else
  7. #include "vogl.h"
  8. #include "vodevice.h"
  9. #endif
  10.  
  11. /*
  12.  * getcharacter
  13.  *
  14.  *    read in a character line from a hershey font file
  15.  */
  16. int getcharacter(
  17.   FILE *fp,
  18.   int *no,
  19.   int *pairs,
  20.   char *buf)
  21. {
  22.     int    i;
  23.     char    *p, tmp[10];
  24.  
  25.     /*
  26.      * read in the numbers
  27.      */
  28.     for (i = 0; i < 5; i++) {
  29.         if ((tmp[i] = fgetc(fp)) == '\n')    /* take care of the odd blank line */
  30.             tmp[i] = fgetc(fp);
  31.         if (feof(fp))
  32.             return(0);
  33.     }
  34.     tmp[5] = 0;
  35.     sscanf(tmp, "%d", no);
  36.         
  37.     for (i = 0; i < 3; i++) {
  38.         tmp[i] = fgetc(fp);
  39.         if (feof(fp))
  40.             return(0);
  41.     }
  42.     tmp[3] = 0;
  43.     sscanf(tmp, "%d", pairs);
  44.         
  45.  
  46.     /*
  47.      * read in the pairs
  48.      */
  49.     for (p = buf, i = 0; i < 2 * *pairs; i++, p++)
  50.         if ((*p = fgetc(fp)) == '\n')
  51.             *p = fgetc(fp);
  52.  
  53.     *p = 0;
  54.  
  55.     fgetc(fp);            /* skip newline at end */
  56.  
  57.     return(1);
  58. }
  59.